package com.jt9003.service.impl;


import com.jt9003.dao.Patient_case_historyMapper;
import com.jt9003.pojo.Patient_case_history2;
import com.jt9003.service.patientCaseHistoryService;

import com.jt9003.utils.PageUtils;
import com.jt9003.utils.RedisUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class patientCaseHistoryServiceImpl implements patientCaseHistoryService {

    @Resource
    Patient_case_historyMapper pchm;
    @Resource
    RedisUtil redisUtil;

    //查询所有患者病例
    @Override
    public List<Patient_case_history2> selectPCH(Map map) {
        Object object = redisUtil.get("midical:patientCaseHistoryController:selectPCH:"+map);
        if (object!=null){
            return (List<Patient_case_history2>)object;
        }else {
            List<Patient_case_history2> list = pchm.selectPCH(map);
            //转换取出的日期格式
            for (Patient_case_history2 pch2 : list) {
                String time = PageUtils.transferDate(pch2.getPreOpenDate());
                pch2.setTime(time);
            }
            redisUtil.set("midical:patientCaseHistoryController:selectPCH:"+map,list,120);
            return list;
        }
    }

    //查询数据总数
    @Override
    public int selectAllData(Map map) {
        return pchm.selectAllData(map);
    }
}
